package interf2;

class Dog2 implements Comparable <Dog2>{
    private int x;
    private double y;
    public Dog2(int x_in, double y_in) {
        x = x_in;
        y = y_in;
    }
    public String toString() {
        return "( " + x + ", " + y + " )";
    }
    public int compareTo(Dog2 o) {
        if (y > o.y)
            return 1;
        if (y < o.y)
            return -1;
        return 0;
    }
}

public class Comparing2 {
    public static void main(String[] args) {
        Dog2 a = new Dog2(4, 5.0);
        Dog2 b = new Dog2(7, 3.2);

        
        System.out.println(" a is " + a);
        System.out.println(" b is " + b);
        
        System.out.println(" comparing a and b: " + a.compareTo(b));
        System.out.println(" comparing b and a: " + b.compareTo(a));
        
        System.out.println(" comparing a and a: " + a.compareTo(a));
        System.out.println(" comparing b and b: " + b.compareTo(b));
    }
}